package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	// 路径表
	type Track struct {
		models.BaseModel

		FromId uint64 `gorm:"column:from_id;comment:region id;" db:"from_id" json:"from_id" form:"from_id"`
		ToId   uint64 `gorm:"column:to_id;comment:region id;" db:"to_id" json:"to_id" form:"to_id"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&Track{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&Track{})
	}

	migrate.Add("2023_07_19_105520_add_tracks_table", up, down)
}
